<template>
  <a-modal
    :visible="visible"
    :title="editId ? '学科信息修改' : '新增学科信息'"
    :confirmLoading="confirmLoading"
    okText='保存'
    :width="1000"
    @cancel="() => { $emit('cancel') }"
    @ok="() => { $emit('create') }"
  >
    <a-form :form="form">
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="学科代码"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input v-decorator="[
              'xkdm',
              {
                rules: [{ required: true, message: '请输入学科代码!' }],
              }
            ]"/>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item
            label="学科名称"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-input v-decorator="[
              'xkmc',
              {
                rules: [{ required: true, message: '请输入学科名称!' }],
              }
            ]"/>
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="学科类别" :labelCol="{span: 7,offset: 1}" :wrapperCol="{span: 15, offset: 1}">
            <a-select v-decorator="['xklb',
              {
                rules: [{ required: true, message: '请选择学科类别!' }]
              }]">
              <a-select-option v-for="i in selectMenu.xklb" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item label="父级" :labelCol="{span: 7,offset: 1}" :wrapperCol="{span: 15, offset: 1}">
            <a-select v-decorator="['fjxkdm']" :allowClear="true" showSearch :filterOption="filterOption">
              <a-select-option v-for="i in selectMenu.subject" :key="i.id" :value="i.xkdm">{{ i.xkdm + ' ' + i.xkmc }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="是否博士后站" :labelCol="{span: 7,offset: 1}" :wrapperCol="{span: 15, offset: 1}">
            <a-select v-decorator="['bshzzk']">
              <a-select-option value="1">是</a-select-option>
              <a-select-option value="0">否</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item label="博士点授予年月" :labelCol="{span: 7,offset: 1}" :wrapperCol="{span: 15, offset: 1}">
            <a-date-picker v-decorator="['bssqny']" style="width: 100%" />
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="是否校重点学科" :labelCol="{span: 7,offset: 1}" :wrapperCol="{span: 15, offset: 1}">
            <a-select v-decorator="['xzdxkzk']">
              <a-select-option value="1">是</a-select-option>
              <a-select-option value="0">否</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item label="硕士点授予年月" :labelCol="{span: 7,offset: 1}" :wrapperCol="{span: 15, offset: 1}">
            <a-date-picker v-decorator="['sssqny']" style="width: 100%" />
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="是否省级重点学科" :labelCol="{span: 7,offset: 1}" :wrapperCol="{span: 15, offset: 1}">
            <a-select v-decorator="['sbjzdxkzk']">
              <a-select-option value="1">是</a-select-option>
              <a-select-option value="0">否</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item label="省部重点学科批准年月" :labelCol="{span: 7,offset: 1}" :wrapperCol="{span: 15, offset: 1}">
            <a-date-picker v-decorator="['sbzdxkpzny']" style="width: 100%" />
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="是否国家重点学科" :labelCol="{span: 7,offset: 1}" :wrapperCol="{span: 15, offset: 1}">
            <a-select v-decorator="['gjzdxkzk']">
              <a-select-option value="1">是</a-select-option>
              <a-select-option value="0">否</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item label="国家重点学科批准年月" :labelCol="{span: 7,offset: 1}" :wrapperCol="{span: 15, offset: 1}">
            <a-date-picker v-decorator="['gjzdxkpzny']" style="width: 100%" />
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="学科授权" :labelCol="{span: 7,offset: 1}" :wrapperCol="{span: 15, offset: 1}">
            <a-select v-decorator="['xksqm']">
              <a-select-option v-for="i in selectMenu.xksqm" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item label="学科授权年月" :labelCol="{span: 7,offset: 1}" :wrapperCol="{span: 15, offset: 1}">
            <a-date-picker v-decorator="['xksqny']" style="width: 100%" />
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="学科点简介" :labelCol="{span: 7,offset: 1}" :wrapperCol="{span: 15, offset: 1}">
            <a-input type="textarea" v-decorator="['note']" :autosize="{ minRows: 2, maxRows: 6 }"/>
          </a-form-item>
        </a-col>
      </a-row>
    </a-form>
  </a-modal>
</template>

<script>
export default {
  props: ['visible', 'editId', 'selectMenu', 'confirmLoading'],
  beforeCreate () {
    this.form = this.$form.createForm(this)
  },
  methods: {
    test (e, a) {
      this.form.setFieldsValue({sxrq: a})
    },
    filterOption (value, options) {
      return options.componentOptions.children[0].text.indexOf(value) !== -1
    }
  }
}
</script>

<style>

</style>
